package com.yxkj.syh.app.huarong.activities.links;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.MutableLiveData;

import com.syh.app.basic.base.view_model.BaseViewModel;
import com.syh.app.basic.utils.Tooast;
import com.syh.app.basic.utils.net.ApiObserver;
import com.trello.rxlifecycle2.android.FragmentEvent;
import com.yxkj.syh.app.huarong.bean.LinkListResponse;
import com.yxkj.syh.app.huarong.bean.PagesRequest;
import com.yxkj.syh.app.huarong.data_center.model.CommonModel;

/**
 * 创建者：SYH
 * 时间：2020/6/4 10:12
 * 编辑者：SYH、
 * 标签：
 * 补充说明：
 */
public class LinksVM extends BaseViewModel<FragmentEvent> {

    public LinksVM(@NonNull Application application) {
        super(application);
    }

    public MutableLiveData<LinkListResponse.Data> mldLinkListResponseData = new MutableLiveData<>();

    public void linkList(PagesRequest pagesRequest){
        CommonModel.getCommonModel().linkList(pagesRequest,mLifecycleProvider.bindToLifecycle(), new ApiObserver<LinkListResponse>() {
            @Override
            public void onSuccess(LinkListResponse response) {
                mldLinkListResponseData.setValue(response.getData());
            }

            @Override
            public void onFailed(int code, String msg) {
                Tooast.warning(msg);
                mldLinkListResponseData.setValue(null);
            }
        });
    }

}
